<template>
  <div>
    <div @click="handleImageClick" v-html="locationInfo" />

    <!-- Image Modal -->
    <div v-if="showModal" class="modal" @click="closeModal">
      <img :src="selectedImage" class="modal-content" @click.stop>
      <div class="close" @click="closeModal">&times;</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Imagezome',
  props: {
    locationInfo: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      showModal: false,
      selectedImage: ''
    }
  },
  // Fetch the location info and set it to locationInfo data property
  mounted() {
    // Example: fetch data from API
    // this.locationInfo = await fetchLocationInfo();
  },
  methods: {
    handleImageClick(event) {
      const target = event.target.closest('[data-image-url]')
      if (target) {
        this.selectedImage = target.dataset.imageUrl
        this.showModal = true
      }
    },
    closeModal() {
      this.showModal = false
    }
  }
}
</script>

<style scoped>
.modal {
  display: flex;
  position: fixed;
  z-index: 1;
  padding-top: 100px;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.9);
  justify-content: center;
  align-items: center;
}

.modal-content {
  margin: auto;
  display: block;
  width: 80%;
  max-width: 700px;
}

.close {
  position: absolute;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  cursor: pointer;
}
</style>
